﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace WpfFeeCalculator.ViewModel
{
    public class MoreFeesViewModel : WorkspaceViewModel
    {
        public ObservableCollection<FeeDetails> FeeDetails { get; set; }
       

        public MoreFeesViewModel()
        {
            FeeDetails = new ObservableCollection<FeeDetails>();
            FeeDetails.Add(new FeeDetails { Id = 1, Name = "manager Fee", FeeType = "Expensive", Gender = "M" });
            FeeDetails.Add(new FeeDetails { Id = 2 ,Name = "Producer Fee", FeeType = "Expensive", Gender = "F" });
           
            FeeName = "Not in the list Fee";
          
        }

        private string _feeName;
        public String FeeName
        {
            get { return _feeName; }
            set
            {
                if (value == _feeName)
                    return;

                _feeName = value;

                base.OnPropertyChanged("FeeName");
            }
        }


        private FeeDetails _feeId;
        public FeeDetails FeeId
        {
            get { return _feeId; }
            set
            {
                if (value == _feeId)
                    return;

                _feeId = value;

                
                   FeeName = _feeId.Name;

                base.OnPropertyChanged("FeeId");
            }
        }

        ICommand _loadCalculationCommand;
        public ICommand LoadCalculationCommand
        {
            get
            {
                if (_loadCalculationCommand == null)
                {
                    _loadCalculationCommand = new RelayCommand(
                        param => this.LoadCalculations()
                        );
                }
                return _loadCalculationCommand;
            }
        }

        public void LoadCalculations()
        {
            
        }


        ICommand _deleteItemCommand;
        public ICommand DeleteItemCommand
        {
            get
            {
                if (_deleteItemCommand == null)
                {
                    _deleteItemCommand = new RelayCommand(
                        param => this.DeleteItem(param)
                        );
                }
                return _deleteItemCommand;
            }
        }

        private object DeleteItem(object param)
        {
            var name = param as string;
            if (name == null)
               throw new NotImplementedException();
            return name;
        }
    }

    public class FeeDetails
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string FeeType { get; set; }
        public string Gender { get; set; }

        public override string ToString()
        {
            return Name;
        }
    }
}
